Added create, update and delete for auth for subdomains#41
Conversation
* uses the naming convention of '*.sitename.tld' when `app_sub_type` is subdom * Passes the $site_type variable to `generate_site_auth_files` for it to use it when deleteing and updating the file. Signed-off-by: Hrishikesh Barman <hrishikeshbman@gmail.com>
| $global = $this->populate_info( $args, __FUNCTION__ ); | ||
| $ips = \EE\Utils\get_flag_value( $assoc_args, 'ip' ); | ||
| $site_url = $global ? 'default' : $this->site_data->site_url; | ||
| $site_type = $global ? 'wp' : $this->site_data->app_sub_type; |
There was a problem hiding this comment.
Need to consider other site types. html and PHP site types have blank $this->site_data->app_sub_type.
So, only check for app_sub_type when 'wp' === $this->site_data->site_type.
|
|
||
| $auth_file_name = ''; | ||
| switch ( $site_type ) { | ||
| case 'wp': |
There was a problem hiding this comment.
All the same cases can go in one. No need to create a seprate block of subdir, just declare all blocks as in sugesstion. Or better yet, as there is a change in only one type of site, i.e., subdom, you can also convert this to single if-else.
| case 'wp': | |
| case 'wp': | |
| case 'subdir': | |
| case 'html': | |
| case 'php': |
| $auth_file_name = $site_url; | ||
| break; | ||
| case 'subdom': | ||
| $auth_file_name = '*.' . $site_url; |
There was a problem hiding this comment.
I am not sure if we still need to have the sitename.tld file in /opt/easyengine/services/nginx-proxy/htpasswd when we already have *.sitename.tld
It is necessary to have both the files.
Yes, in case of subdom site, create two files:
|
See : https://github.com/rtCamp/sys/issues/176#issuecomment-509517284
This PR attempts to add basic auth add, update and delete support when we create a site with
--mu=subdomwith ee4.*.sitename.tldwhenapp_sub_typeissubdom$site_typevariable togenerate_site_auth_filesfor it to use it when deleteing and updating the file.I am not sure if we still need to have the
sitename.tldfile in/opt/easyengine/services/nginx-proxy/htpasswdwhen we already have*.sitename.tldAdditionally, should we do the same for the IP whitelisting?
cc @mrrobot47
Signed-off-by: Hrishikesh Barman hrishikeshbman@gmail.com